package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Dish;
import com.sky.result.Result;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @AutoFill(OperationType.INSERT)
    void save(Dish dish);

    @AutoFill(OperationType.UPDATE)
   void update(Dish dish);

    //@Select("select * from dish where category_id = #{categoryId} and name like concat('%',#{name},'%') and status = #{status}")
    Page<DishVO> page(Integer categoryId, String name, Integer status);

    void deleteByIds(@Param("ids") Long[] ids);

    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> list(Integer categoryId);

    @Select("select * from dish left join  category on category.id=dish.category_id where dish.id=#{id} ")
    DishVO getById(Long id);


    List<Dish> list1(Dish dish);


    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    Integer selectDishCountByIdsAndStatus(@Param("ids") List<Long> ids,
                                          @Param("status") Integer enable);



}
